feat(cli): default output to JSON for coding agents#5532
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 333917938d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase@5532Preview package for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c907b6cdf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c2f5e4c66b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary
Coding agents that run the CLI now get JSON output by default, so they
can parse structured results instead of scraping human-formatted tables.
I resolve the effective output format once at the TypeScript entrypoint
(both the legacy and next roots): an explicit `--output` /
`--output-format` always wins, otherwise a detected coding agent gets
`json` and everyone else keeps `text`. For Go-proxied commands this
flows down as `--output json` to the Go subprocess, which renders JSON
for the data-returning commands and ignores the flag elsewhere, so no Go
changes were needed.
## Changes
- Resolve output format from coding-agent detection in both CLI roots,
defaulting agents to `json` when no format is set explicitly.
- Add a shared `resolveAgentOutputFormat` helper (`explicit ?? (agent ?
json : text)`) reused by both roots, with unit tests.
- Make the `--output-format` global flag optional so an
explicitly-passed format is distinguishable from the default.
- Suppress the agent JSON default whenever the Go-compat `-o`/`--output`
flag is passed explicitly: `-o json|yaml|toml|env` already
short-circuits inside handlers, and `-o pretty` now keeps rendering the
human table on natively ported commands instead of being overridden to
JSON.
## Behavior notes
- Humans and CI keep their current output: production telemetry shows
~99.6% of CI invocations carry no coding-agent env signal, so they don't
flip.
- Error rendering follows the resolved format. In text mode errors stay
as red text on stderr, unchanged. In agent-default JSON mode handler
errors emit the existing structured envelope
(`{"_tag":"Error","error":{code,message}}`) on stdout with a non-zero
exit code, the same behavior `--output-format json` already had, so
agents get parseable failures instead of prose.
- Interactive prompts already refuse to block in JSON mode
(`NonInteractiveError`), so a detected agent cannot hang on a confirm
prompt.
- `--help` and `--version` render before the output layer engages and
stay text in both roots.
- `--agent yes|no` overrides detection in both directions for the
default-format decision.
## Linear
- fixes GROWTH-913
---------
Co-authored-by: Julien Goux <hi@jgoux.dev>
Summary
Coding agents that run the CLI now get JSON output by default, so they can parse structured results instead of scraping human-formatted tables. I resolve the effective output format once at the TypeScript entrypoint (both the legacy and next roots): an explicit
--output/--output-formatalways wins, otherwise a detected coding agent getsjsonand everyone else keepstext. For Go-proxied commands this flows down as--output jsonto the Go subprocess, which renders JSON for the data-returning commands and ignores the flag elsewhere, so no Go changes were needed.Changes
jsonwhen no format is set explicitly.resolveAgentOutputFormathelper (explicit ?? (agent ? json : text)) reused by both roots, with unit tests.--output-formatglobal flag optional so an explicitly-passed format is distinguishable from the default.-o/--outputflag is passed explicitly:-o json|yaml|toml|envalready short-circuits inside handlers, and-o prettynow keeps rendering the human table on natively ported commands instead of being overridden to JSON.Behavior notes
{"_tag":"Error","error":{code,message}}) on stdout with a non-zero exit code, the same behavior--output-format jsonalready had, so agents get parseable failures instead of prose.NonInteractiveError), so a detected agent cannot hang on a confirm prompt.--helpand--versionrender before the output layer engages and stay text in both roots.--agent yes|nooverrides detection in both directions for the default-format decision.Linear